<?php

namespace App\Http\Resources;

use App\Models\Category;
use App\Models\TaskDetail;
use Illuminate\Http\Resources\Json\JsonResource;

class TaskDetailResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'type' => getDictValue('task_type',$this->type),
            'category' => Category::query()->where('id',$this->category_id)->value('name'),
            'singular' => $this->singular,
            'price' => $this->price,
            'valid_time' => getDictValue('valid_time',$this->valid_time),
            'status' => getDictValue('task_status',$this->status),
            'created_at' => getDateTime($this->created_at),
            'detail' => $this->detail,
            'certified_chart' => $this->certified_chart,
        ];
    }
}
